//
//  TestCell.h
//  TapTest
//
//  Created by 申鸿凯 on 2017/10/10.
//  Copyright © 2017年 shenhk. All rights reserved.
//

#import "TestCell.h"
#import <Masonry.h>

@implementation TestCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initSubviews];
    }
    return self;
}

- (void)initSubviews
{
    UIButton *button = [UIButton new];
    button.backgroundColor = [UIColor brownColor];
    
    [button setTitle:@"我是cell上的按钮" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [button addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.contentView addSubview: button];
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.centerX.equalTo(self.contentView);
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.width.mas_equalTo(200);
    }];
}

- (void)click:(UIButton *)sender
{
    NSLog(@"点击了cell上的button");
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
